$(function(){
	 $("#sinaLogin").bind("click",sinaLogin);
	 $('li.mainlevel').mousemove(function(){
		  $(this).find('ul').slideDown();//you can give it a speed
		  });
	  $('li.mainlevel').mouseleave(function(){
	  $(this).find('ul').slideUp("fast");
	  });
});


function sinaLogin(){
	
//	var client_id = "1648372436";//大地微连接appKey
//	var redirect_uri = "../index.htm"/*tpa=http://www.95590.cn/*/;//微博登陆回调页
	var client_id = "3962707802";
//	var redirect_uri = "http://127.0.0.1/ebw/view/weiboLogin/wbLogin.jsp";
	var redirect_uri = "http://testzdf.com/ebw/view/weiboLogin/wbAutoLogin.jsp";
	var response_type = "token";
	var state = "1";
	var url = "https://api.weibo.com/oauth2/authorize?client_id="+client_id+"&redirect_uri="+redirect_uri+"&response_type="+response_type+"&state="+state;
	window.open(url,'_blank');
//	window.open (url, 'newwindow', 'height=300px, width=600px, scrollbars=yes, resizable=yes');
}

function login () {
		/* var backUrl = top.location.href;
		var params = parse_url(backUrl);
		var loginBackUrl = params["loginBackUrl"];
		if(!(typeof(loginBackUrl) == "undefined")){
			return;
		}
		//在login页面时，不再拼接backUrl
		if(backUrl!=null&&backUrl!=""){
			if (backUrl.indexOf("login.jsp.htm"/*tpa=http://www.95590.cn/ebiz/login.jsp*/)<=0)
			{}
			else{return;}
		} */
			
		//取页面上的回跳页，有则直接拼上
		var commonLoginBackUrl = $("#commonLoginBackUrl",window.parent.document).val();
		if(commonLoginBackUrl!=""&&commonLoginBackUrl!=null){
			commonLoginBackUrl = commonLoginBackUrl.replace(/\&/ig,"$");
			window.parent.location.href = Newtouch.context+"/loginSkin.jsp?loginBackUrl="+commonLoginBackUrl;
		}else{
			var backUrl = top.location.href;
			backUrl = backUrl.replace(/\&/ig,"$");
			/* var params = parse_url(backUrl);
			var loginBackUrl = params["loginBackUrl"];
			$("#commonLoginBackUrl").val(loginBackUrl); */
			window.parent.location.href = Newtouch.context+"/loginSkin.jsp?loginBackUrl="+backUrl;
			
		}
		/* var loginBackUrl = window.parent.location;  */
		
	
}

function parse_url(_url){ 
    var pattern = /(\w+)=([\w\.\_\/#:]+)/ig;
    var parames = {};
    _url.replace(pattern, function(a, b, c){parames[b] = c;});//反向引用，正则表达式子匹配
    return parames;
}

//isCarHead参数用来描述是否通过carHead进入注册页面
function register() {
	var commonLoginBackUrl = $("#commonLoginBackUrl",window.parent.document).val();
	if(commonLoginBackUrl!=""&&commonLoginBackUrl!=null){
		commonLoginBackUrl = commonLoginBackUrl.replace(/\&/ig,"$");
		window.parent.location.href = Newtouch.context+"/view/userskin/personRegSkin.jsp?isCarHead=1&loginBackUrl="+commonLoginBackUrl;
	}else{
		window.parent.location.href = Newtouch.context+"/view/userskin/personRegSkin.jsp?isCarHead=1&loginBackUrl="+Newtouch.context+"/view/user_newStyle/userMain.jsp";
	}	
}

function gotoShopping(){
	window.parent.location.href = Newtouch.context+"/view/cart/cartAndPay.jsp?shoppingDetail=1";	
}

function logout() {
	window.parent.location.href = Newtouch.context+"/j_spring_security_logout";
}

function zhanghu() {
	window.parent.location.href = Newtouch.context+"/view/user_newStyle/userMain.jsp";
}

function myToubao(menuName,menuBarName) {
	var userType = document.getElementById("carHead_regUserType").value;
	//存入cookie
	setCookieNoLimit("ebiz_menuName",menuName);
	setCookieNoLimit("ebiz_menuBarName",menuBarName);
	setCookieNoLimit("ebiz_userType",userType);
	setCookieNoLimit("flag","flag");
	window.parent.location.href = Newtouch.context+"/view/user_newStyle/userMain.jsp?menuBarName="+menuBarName+"&userType="+userType+"&menuName="+menuName+"&flag=flag";
	
}
function toOnlinePayment(){
	window.parent.location.href = Newtouch.context+"/view/mainFirstView.jsp";
}
function toSettlement(){
	window.parent.location.href = Newtouch.context+"/view/onlineBusiness/onlineServiceMain.jsp";
}
function toManual(){
	window.open(Newtouch.context+"/view/onlineser/sguide.html",'newwindow', 'height=500, width=800,scrollbars=yes');
	
}